How To Find Out If You are Using HTTPS Without $_SERVER['HTTPS']

Posted by Chacha102 on Stack Overflow See other posts from Stack Overflow or by Chacha102
Published on 2009-07-23T23:42:49Z Indexed on 2010/05/21 23:30 UTC
Read the original article Hit count: 815

Filed under:
|

I've seen many tutorials online that says you need to check $_SERVER['HTTPS'] if the server is connection is secured with HTTPS. My problem is that on some of the servers I use, $_SERVER['HTTPS'] is an undefined variable that results in an error. Is there another variable I can check that should always be defined?

Just to be clear, I am currently using this code to resolve if it is an HTTPS connection:

if(isset($_SERVER['HTTPS']))
{
    if ($_SERVER["HTTPS"] == "on") 
    {
        $secure_connection = true;
    }
}

© Stack Overflow or respective owner

Related posts about php

Related posts about https